package jodis.conn.impl;

import jodis.JoConstants;
import jodis.conn.inter.IReply;

import java.nio.charset.StandardCharsets;

public class StandardErrReply implements IReply {
    private String status;

    public StandardErrReply(String status) {
        this.status = status;
    }

    public static StandardErrReply makeErrReply(String status) {
        return new StandardErrReply(status);
    }

    @Override
    public byte[] toBytes() {
        return String.format("-%s%s", this.status, JoConstants.CRLF).getBytes(StandardCharsets.UTF_8);
    }

    public String error() {
        return status;
    }
}
